﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TraitorAmongUs.Common {
	public abstract class Singleton<T> where T : Singleton<T>, new() {
		private volatile static T instance;
		private static object lockObject = new object();

		protected static T GetInstance() {
			if(instance == null) {
				lock(lockObject) {
					if(instance == null) {
						instance = new T();
					}
				}
			}

			return instance;
		}

		public static T Instance {
			get {
				return GetInstance();
			}
		}
	}
}
